<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch">
      <el-form-item label="发送人员姓名" prop="yuser">
        <el-input v-model="queryParams.yuser" placeholder="请输入 " clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button type="success" plain icon="el-icon-edit" size="mini" :disabled="single" @click="handleUpdate"
<<<<<<< HEAD
          v-hasPermi="['system:xxqk:list']">处理</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport"
          v-hasPermi="['system:xxqk:list']">导出</el-button>
=======
          v-hasPermi="['system:xxqk:edit']">处理</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport"
          v-hasPermi="['system:xxqk:export']">导出</el-button>
>>>>>>> b4a0e2dba4b1f1e0b05e6d155df4272830d06f27
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>
    <div>
      <h2>异常接收区域</h2>
    </div>
    <el-table v-loading="loading" :data="xxqkList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="状况描述" width="600" align="center" prop="yname" />
      <el-table-column label="发送时间" align="center" prop="ytime" />
      <el-table-column label="发送地点" align="center" prop="yfsdd" />
      <el-table-column label="发送人员姓名" align="center" prop="yuser" />
      <!-- <el-table-column label=" " align="center" prop="cname" />
      <el-table-column label=" " align="center" prop="ctime" />
      <el-table-column label=" " align="center" prop="cuser" />
      <el-table-column label=" " align="center" prop="cfsdd" />
      <el-table-column label=" " align="center" prop="yztxx" />
      <el-table-column label=" " align="center" prop="jcycAHk" />
      <el-table-column label=" " align="center" prop="jcycBHk" /> -->
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)"
<<<<<<< HEAD
            v-hasPermi="['system:xxqk:list']">处理</el-button>
=======
            v-hasPermi="['system:xxqk:edit']">处理</el-button>
>>>>>>> b4a0e2dba4b1f1e0b05e6d155df4272830d06f27
          <!-- <el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)"
            v-hasPermi="['system:xxqk:remove']">删除</el-button> -->
        </template>
      </el-table-column>
    </el-table>
    <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
      @pagination="getList" />
    <div>
      <h2>异常处理完成区域</h2>
    </div>
    <div>
      <chuliwancheng></chuliwancheng>
    </div>
    <!-- 添加或修改异常接收对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
        <!-- <el-form-item label="序号" prop="id">
          <el-input v-model="form.id" placeholder="请输入 " />
        </el-form-item> -->
        <el-form-item label="状况描述" prop="yname">
          <el-input v-model="form.yname" type="textarea" readonly />
        </el-form-item>
        <el-form-item label="发送时间" prop="ytime">
          <el-input v-model="form.ytime" readonly />
        </el-form-item>
        <el-form-item label="发送地点" prop="yfsdd">
          <el-input v-model="form.yfsdd" readonly />
        </el-form-item>
        <el-form-item label="发送人员" prop="yuser">
          <el-input v-model="form.yuser" readonly />
        </el-form-item>
        <el-form-item label="处理备注" prop="cname">
          <el-input v-model="form.cname" placeholder="请输入 " />
        </el-form-item>
        <!-- <el-form-item label="处理人员" prop="cuser">
          <el-input v-model="form.cuser" placeholder="请输入 " />
        </el-form-item> -->
        <!-- <el-form-item label="处理时间" prop="cfsdd">
          <el-input v-model="form.cfsdd" placeholder="请输入 " />
        </el-form-item> -->
        <el-form-item label="状态" prop="yztxx">
          <el-select v-model="form.yztxx" placeholder="请选择状态">
            <el-option label="完成" value="完成"></el-option>
            <el-option label="未完成" value="未完成"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="照片1" prop="jcycAHk">
          <el-input v-model="form.jcycAHk" type="textarea" readonly />
        </el-form-item>
        <el-form-item label="照片2" prop="jcycBHk">
          <el-input v-model="form.jcycBHk" type="textarea" readonly />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { listXxqk, getXxqk, delXxqk, addXxqk, updateXxqk } from "@/api/system/Fdongbei/xxqk";
import chuliwancheng from "@/views/Fdongbei/xxqk/chuliwancheng";
export default {
  name: "Xxqk",
  components: { chuliwancheng },
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 异常接收表格数据
      xxqkList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        yname: null,
        ytime: null,
        yfsdd: null,
        yuser: null,
        cname: null,
        ctime: null,
        cuser: null,
        cfsdd: null,
        yztxx: null,
        jcycAHk: null,
        jcycBHk: null
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
        id: [
          { required: true, message: " 不能为空", trigger: "blur" }
        ],
      }
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询异常接收列表 */
    getList() {
      this.loading = true;
      listXxqk(this.queryParams).then(response => {
        this.xxqkList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        yname: null,
        ytime: null,
        yfsdd: null,
        yuser: null,
        cname: null,
        ctime: null,
        cuser: null,
        cfsdd: null,
        yztxx: null,
        jcycAHk: null,
        jcycBHk: null
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.single = selection.length !== 1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加异常接收";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const id = row.id || this.ids
      getXxqk(id).then(response => {
        this.form = response.data;
        this.open = true;
        this.title = "处理异常";
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.id != null) {
            this.form.cuser = this.$store.state.user.name;
            this.form.ctime = new Date().toLocaleString();
            this.form.cfsdd = '总处理端';
            updateXxqk(this.form).then(response => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addXxqk(this.form).then(response => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$modal.confirm('是否确认删除异常接收编号为"' + ids + '"的数据项？').then(function () {
        return delXxqk(ids);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => { });
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('system/xxqk/export', {
        ...this.queryParams
      }, `xxqk_${new Date().getTime()}.xlsx`)
    }
  }
};
</script>
